use cargo::execute_main_without_stdin;
use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult};
use cargo::util::CliError;
-use cargo::util::process_builder::process;
#[derive(RustcDecodable)]
pub struct Flags {
}
if let Some(ref code) = flags.flag_explain {
- try!(process(&*try!(config.rustc()))
- .arg("--explain").arg(code).exec()
- .map_err(human));
+ let mut procss = try!(config.rustc()).process();
+ try!(procss.arg("--explain").arg(code).exec().map_err(human));
return Ok(None)
}
let packages = ops::get_resolved_packages(&resolve, registry);
let profiles = try!(ws.current()).manifest().profiles();
- let host_triple = try!(opts.config.rustc_info()).host.clone();
+ let host_triple = try!(opts.config.rustc()).host.clone();
let mut cx = try!(Context::new(ws, &resolve, &packages, opts.config,
BuildConfig {
host_triple: host_triple,
let cfg_target = try!(config.get_string("build.target")).map(|s| s.val);
let target = target.or(cfg_target);
let mut base = ops::BuildConfig {
- host_triple: try!(config.rustc_info()).host.clone(),
+ host_triple: try!(config.rustc()).host.clone(),
requested_target: target.clone(),
jobs: jobs,
..Default::default()
use core::{Package, PackageId, PackageSet, Resolve, Target, Profile};
use core::{TargetKind, Profiles, Metadata, Dependency, Workspace};
use core::dependency::Kind as DepKind;
-use util::{self, CargoResult, ChainError, internal, Config, profile, Cfg, human};
+use util::{CargoResult, ChainError, internal, Config, profile, Cfg, human};
use super::TargetConfig;
use super::custom_build::{BuildState, BuildScripts};
&self.build_config,
kind,
"RUSTFLAGS"));
- let mut process = util::process(&*try!(self.config.rustc()));
+ let mut process = try!(self.config.rustc()).process();
process.arg("-")
.arg("--crate-name").arg("_")
.arg("--print=file-names")
.env("OPT_LEVEL", &profile.opt_level.to_string())
.env("PROFILE", if cx.build_config.release {"release"} else {"debug"})
.env("HOST", cx.host_triple())
- .env("RUSTC", &*try!(cx.config.rustc()))
+ .env("RUSTC", &try!(cx.config.rustc()).path)
.env("RUSTDOC", &*try!(cx.config.rustdoc()));
if let Some(links) = unit.pkg.manifest().links(){
Ok(CommandPrototype {
builder: {
let mut p = match ty {
- CommandType::Rustc => process(&*try!(config.rustc())),
+ CommandType::Rustc => try!(config.rustc()).process(),
CommandType::Rustdoc => process(&*try!(config.rustdoc())),
CommandType::Target(ref s) |
CommandType::Host(ref s) => process(s),
try!(cx.rustflags_args(unit))
};
let fingerprint = Arc::new(Fingerprint {
- rustc: util::hash_u64(&try!(cx.config.rustc_info()).verbose_version),
+ rustc: util::hash_u64(&try!(cx.config.rustc()).verbose_version),
target: util::hash_u64(&unit.target),
profile: util::hash_u64(&unit.profile),
features: format!("{:?}", features),
let name = unit.pkg.name().to_string();
if !cx.show_warnings(unit.pkg.package_id()) {
- if try!(cx.config.rustc_info()).cap_lints {
+ if try!(cx.config.rustc()).cap_lints {
rustc.arg("--cap-lints").arg("allow");
} else {
rustc.arg("-Awarnings");
// We don't build/rust doctests if target != host
if let Some(target) = options.compile_opts.target {
- if try!(config.rustc_info()).host != target {
+ if try!(config.rustc()).host != target {
return Ok(errors);
}
}
pub struct Config {
home_path: Filesystem,
shell: RefCell<MultiShell>,
- rustc_info: RefCell<Option<Rustc>>,
+ rustc: RefCell<Option<Rustc>>,
values: RefCell<HashMap<String, ConfigValue>>,
values_loaded: Cell<bool>,
cwd: PathBuf,
let mut cfg = Config {
home_path: Filesystem::new(homedir),
shell: RefCell::new(shell),
- rustc_info: RefCell::new(None),
+ rustc: RefCell::new(None),
cwd: cwd,
values: RefCell::new(HashMap::new()),
values_loaded: Cell::new(false),
self.shell.borrow_mut()
}
- pub fn rustc(&self) -> CargoResult<Ref<Path>> {
- let rustc = try!(self.rustc_info());
- Ok(Ref::map(rustc, |r| r.path.as_ref()))
- }
-
pub fn rustdoc(&self) -> CargoResult<Ref<Path>> {
if self.rustdoc.borrow().is_none() {
*self.rustdoc.borrow_mut() = Some(try!(self.get_tool("rustdoc")));
Ok(Ref::map(self.rustdoc.borrow(), |opt| opt.as_ref().map(AsRef::as_ref).unwrap()))
}
- pub fn rustc_info(&self) -> CargoResult<Ref<Rustc>> {
- if self.rustc_info.borrow().is_none() {
+ pub fn rustc(&self) -> CargoResult<Ref<Rustc>> {
+ if self.rustc.borrow().is_none() {
let path = try!(self.get_tool("rustc"));
- *self.rustc_info.borrow_mut() = Some(try!(Rustc::new(path)));
+ *self.rustc.borrow_mut() = Some(try!(Rustc::new(path)));
}
- Ok(Ref::map(self.rustc_info.borrow(), |opt| opt.as_ref().unwrap()))
+ Ok(Ref::map(self.rustc.borrow(), |opt| opt.as_ref().unwrap()))
}
pub fn values(&self) -> CargoResult<Ref<HashMap<String, ConfigValue>>> {
use std::path::PathBuf;
-use util::{self, CargoResult, internal, ChainError};
+use util::{self, CargoResult, internal, ChainError, ProcessBuilder};
pub struct Rustc {
pub path: PathBuf,
cap_lints: cap_lints,
})
}
+
+ pub fn process(&self) -> ProcessBuilder {
+ util::process(&self.path)
+ }
}
use cargo::util::Rustc;
use std::ffi::OsStr;
use std::time::Duration;
+use std::path::PathBuf;
pub mod support;
pub mod install;
-thread_local!(pub static RUSTC: Rustc = Rustc::new("rustc").unwrap());
+thread_local!(pub static RUSTC: Rustc = Rustc::new(PathBuf::from("rustc")).unwrap());
pub fn rustc_host() -> String {
RUSTC.with(|r| r.host.clone())